﻿/******************************************************************
** 文 件 名: Bu_AuditTable_Invoice_DAL.cs
** Copyright (c) 2010-2012 Honestysoft (GuangZhou) Co.,LTD
** 创 建 人: 此代码由生成器自动生成
** 创建日期: 2012-4-24 11:16:02
** 描    述: 实现公共部分的数据访问封装，提供内部审核作业表--发票信息的数据访问类
** 版    本: 2.0.0.0
** 修改描述:
** 修 改 人:
** 修改日期:
******************************************************************/
using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Text;
using Honestysoft.BaseObject;
using Honestysoft.Financing.Model;

namespace Honestysoft.Financing.DataAccess
{
	/// <summary>
    /// Bu_AuditTable_Invoice数据访问类
    /// </summary>
	public partial class Bu_AuditTable_Invoice_DAL : BaseDataAccess<Bu_AuditTable_Invoice>
    {		
		/// <summary>
        /// 构造函数，使用指定的连接字符串
        /// </summary>
        /// <param name="connectionStringName">连接字符串名称</param>
        public Bu_AuditTable_Invoice_DAL(string connectionStringName)
            : base(connectionStringName)
        {

        }
        /// <summary>
        /// 得到是否已有使用发票
        /// </summary>
        /// <param name="id"></param>
        /// <param name="lsNo"></param>
        /// <param name="lsCode"></param>
        /// <returns></returns>
        public DataTable GetExistsInvoice(string id, string no, string code)
        {
            DbParameter pTableID = CreateParameter("TableID");
            pTableID.DbType = DbType.String;
            pTableID.Value = id;
            DbParameter pNo = CreateParameter("InvoiceNo");
            pNo.DbType = DbType.String;
            pNo.Value = no;
            DbParameter pCode = CreateParameter("InvoiceCode");
            pCode.DbType = DbType.String;
            pCode.Value = code;
            string sql = string.Format(@"Select B.Code,A.* From Bu_AuditTable_Invoice A Inner Join Bu_AuditTable B On A.TableID=B.ID
                Where A.TableID <> {0} And A.InvoiceNo={1}
                And A.InvoiceCode={2}", pTableID.ParameterName,pNo.ParameterName,pCode.ParameterName);
            DbCommand command = GetDbCommand(sql);
            command.Parameters.Add(pTableID);
            command.Parameters.Add(pNo);
            command.Parameters.Add(pCode);
            return ExecuteDataTable(command);
        }
    }
}
